<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jsp/include/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title><%=system_name%> - 订单信息</title>
	<%@include file="/WEB-INF/jsp/include/meta.jsp"%>
	
	<link href="<%=basePath%>css/public.css" rel="stylesheet" type="text/css">
	<link href="<%=basePath%>css/index.css" rel="stylesheet" type="text/css">
	<link href="<%=basePath%>css/common.css" rel="stylesheet" type="text/css" />
	<script src="<%=basePath%>js/common.js" type="text/javascript"></script>
	
	<script type="text/javascript" src="js/pagebar.js"></script>
	<script type="text/javascript" src="fram/engine.js" ></script>
	<script type="text/javascript" src="fram/util.js" ></script>
	<script type="text/javascript" src="fram/interface/orderService.js"></script>
</head>

<body oncontextmenu='return false'>

	<!--right begin-->
    <div class="fl right">
    
    		<!--产品详细信息 begin-->	
    		<div class="titleBg">
            	<div class="fl"><img src="images/rightTitleLeft.jpg" alt="left" /></div>
            	<div class="fl title"><span class="marking1"></span>订单信息&nbsp;&nbsp;(业务员：${orderForm.user.userName}，合同号：${orderForm.orderCode})</div>
                <div class="fr"><img src="images/rightTitleRight.jpg" alt="left" /></div>
            </div>
            <div id="clear"></div>
            
            <div class="rightBorder">
            
                <div class="property1">
                <table width="100%" border="0" cellspacing="1" cellpadding="5" bgcolor="#dfe5e9">
                  <tr>
                    <td width="10%" align="right" bgcolor="#dfe5e9">客户国家：</td>
                    <th width="20%" align="left" bgcolor="#dfe5e9">${orderForm.customerCountry}</th>                        
                    <td width="10%" align="right" bgcolor="#dfe5e9">总金额：</td>
                    <th width="10%" align="left" bgcolor="#dfe5e9">${orderForm.totalAmount}</th>
                    <td width="10%" align="right">价格术语：</td>
                    <th width="10%" align="left" bgcolor="#dfe5e9">${orderForm.priceTerms}</th>
                    <td width="10%" align="right">成交方式：</td>
                    <th width="10%" align="left" bgcolor="#dfe5e9">${orderForm.transactionMethod}</th>
                    <th width="10%" align="left" bgcolor="#dfe5e9">备注</th>
                  </tr>
                    
                  <tr>
                    <td align="right">客户公司：</td>
                    <th align="left">${orderForm.customerCompany}</th>
                    <td align="right">总件数：</td>
                    <th align="left" bgcolor="#dfe5e9">${orderForm.totalNumber}</th>
                    <td align="right">成交日期：</td>
                    <th align="left"><fmt:formatDate value="${orderForm.closingDate}" pattern="yyyy.MM.dd"/></th>
                    <td width="10%" align="right">出货日期：</td>
                    <th align="left" bgcolor="#dfe5e9"><fmt:formatDate value="${orderForm.dateShipment}" pattern="yyyy.MM.dd"/></th>
                    <th align="left" bgcolor="#dfe5e9" rowspan="3"><label title="${orderForm.detail1}">${fne:subStringB(orderForm.detail1,'...',0,10)}</label></th>
                  </tr>
                  <tr>
                    <td align="right">客户名字：</td>
                    <th align="left">${orderForm.customerName}</th>
                    <td align="right">总毛重：</td>
                    <th align="left">${orderForm.grossWeight}</th>
                    <td align="right">出货口岸：</td>
                    <th align="left">${orderForm.startShipment}</th>
                    <td width="10%" align="right">订单状态：</td>
                    <th align="left" bgcolor="#dfe5e9">${orderForm.status.codeName}</th>
                  </tr>
                  <tr>
                    <td align="right">客户等级：</td>
                    <th align="left">${orderForm.customerGrade.codeName}</th>
                    <td align="right">总体积：</td>
                    <th align="left">${orderForm.totatlVolume}</th>
                    <td align="right">运抵口岸：</td>
                    <th align="left">${orderForm.endShipment}</th>
                    <td width="10%" align="right">订单打分：</td>
                    <th align="left" bgcolor="#dfe5e9">${orderForm.scoring}分</th>                  
                  </tr>
                  </table>                
      			  </div>
          	  <div id="clear"></div>            
            </div>
            <!--产品详细信息 end-->
            
            <!--产品详细信息 begin-->	
    		<div class="titleBg">
            	<div class="fl"><img src="images/rightTitleLeft.jpg" alt="left" /></div>
            	<div class="fl title"><span class="marking1"></span>客户收款情况</div>
                <div class="fr"><img src="images/rightTitleRight.jpg" alt="left" /></div>
            </div>
            <div id="clear"></div>
            
            <div class="rightBorder">
            
                <div class="property1">
                <table width="100%" border="0" cellspacing="1" cellpadding="5" bgcolor="#dfe5e9">
                      <tr>
                        <td width="18%" align="center" bgcolor="#dfe5e9" colspan="2">客户第1次付款：</td>
                        <td width="18%" align="center" bgcolor="#dfe5e9" colspan="2">客户第2次付款：</td>
                        <td width="18%" align="center" colspan="2">客户第3次付款：</td>
                        <td width="18%" align="center" colspan="2">客户第4次付款：</td>
                        <td width="18%" align="center" colspan="2">收款统计：</td>
                        <td width="10%" align="center" bgcolor="#dfe5e9">备注</td>
                      </tr>                    
                  <tr>
                    <td align="right">付款金额：</td>
                    <th align="left">${orderForm.paymentAmount1}</th>
                    <td align="right">付款金额：</td>
                    <th align="left" bgcolor="#dfe5e9">${orderForm.paymentAmount2}</th>
                    <td align="right">付款金额：</td>
                    <th align="left">${orderForm.paymentAmount3}</th>
                    <td align="right">付款金额：</td>
                    <th align="left">${orderForm.paymentAmount4}</th>
                    <td align="right">客户付款总额：</td>
                    <th align="left">${orderForm.paymentAmount1+orderForm.paymentAmount2+orderForm.paymentAmount3+orderForm.paymentAmount4}</th>
                    <th align="left" rowspan="6"><label title="${orderForm.detail2}">${fne:subStringB(orderForm.detail2,'...',0,10)}</label></th>
                  </tr>
                  <tr>
                    <td align="right">银行费用：</td>
                    <th align="left">${orderForm.bankCharges1}</th>
                    <td align="right">银行费用：</td>
                    <th align="left" bgcolor="#dfe5e9">${orderForm.bankCharges2}</th>
                    <td align="right">银行费用：</td>
                    <th align="left">${orderForm.bankCharges3}</th>
                    <td align="right">银行费用：</td>
                    <th align="left">${orderForm.bankCharges4}</th>
                    <td align="right">银行费用总额：</td>
                    <th align="left">${orderForm.bankCharges1+orderForm.bankCharges2+orderForm.bankCharges3+orderForm.bankCharges4}</th>
                  </tr>
                  <tr>
                    <td align="right">实际收入：</td>
                    <th align="left">${orderForm.realIncome1}</th>
                    <td align="right">实际收入：</td>
                    <th align="left" bgcolor="#dfe5e9">${orderForm.realIncome2}</th>
                    <td align="right">实际收入：</td>
                    <th align="left">${orderForm.realIncome3}</th>
                    <td align="right">实际收入：</td>
                    <th align="left">${orderForm.realIncome4}</th>
                    <td align="right">实际收入总额：</td>
                    <th align="left">${orderForm.realIncome1+orderForm.realIncome2+orderForm.realIncome3+orderForm.realIncome4}</th>
                  </tr>
                  <tr>
                    <td align="right">结汇收入：</td>
                    <th align="left">${orderForm.exchangeIncome1}</th>
                    <td align="right">结汇收入：</td>
                    <th align="left" bgcolor="#dfe5e9">${orderForm.exchangeIncome2}</th>
                    <td align="right">结汇收入：</td>
                    <th align="left">${orderForm.exchangeIncome3}</th>
                    <td align="right">结汇收入：</td>
                    <th align="left">${orderForm.exchangeIncome4}</th>
                    <td align="right">结汇收入总额：</td>
                    <th align="left">${orderForm.exchangeIncome1+orderForm.exchangeIncome2+orderForm.exchangeIncome3+orderForm.exchangeIncome4}</th>
                  </tr>
                  <tr>
                    <td align="right">收款账户：</td>
                    <th align="left">${orderForm.customerAccount1}</th>
                    <td align="right">收款账户：</td>
                    <th align="left" bgcolor="#dfe5e9">${orderForm.customerAccount2}</th>
                    <td align="right">收款账户：</td>
                    <th align="left">${orderForm.customerAccount3}</th>
                    <td align="right">收款账户：</td>
                    <th align="left">${orderForm.customerAccount4}</th>
                    <td align="right"></td>
                    <th align="left"></th>
                  </tr>
                  <tr>
                    <td align="right">时间：</td>
                    <th align="left"><fmt:formatDate value="${orderForm.paymentTime1}" pattern="yyyy.MM.dd"/></th>
                    <td align="right">时间：</td>
                    <th align="left" bgcolor="#dfe5e9"><fmt:formatDate value="${orderForm.paymentTime2}" pattern="yyyy.MM.dd"/></th>
                    <td align="right">时间：</td>
                    <th align="left"><fmt:formatDate value="${orderForm.paymentTime3}" pattern="yyyy.MM.dd"/></th>
                    <td align="right">时间：</td>
                    <th align="left"><fmt:formatDate value="${orderForm.paymentTime4}" pattern="yyyy.MM.dd"/></th>
                    <td align="right"></td>
                    <th align="left"></th>
                  </tr>
                  </table>                
      			  </div>
          	  <div id="clear"></div>            
            </div>
            <!--产品详细信息 end-->
            
            <!--产品详细信息 begin-->	
    		<div class="titleBg">
            	<div class="fl"><img src="images/rightTitleLeft.jpg" alt="left" /></div>
            	<div class="fl title"><span class="marking1"></span>工厂付款情况</div>
                <div class="fr"><img src="images/rightTitleRight.jpg" alt="left" /></div>
            </div>
            <div id="clear"></div>
            
            <div class="rightBorder">
            
                <div class="property1">
                <table width="100%" border="0" cellspacing="1" cellpadding="5" bgcolor="#dfe5e9">
                      <tr>
                        <td width="14%" align="center" bgcolor="#dfe5e9">合作工厂</td>
                        <td width="9%" align="center" bgcolor="#dfe5e9">合同总金额</td>                        
                        <td width="14%" align="center" bgcolor="#dfe5e9">价格条款</td>
                        <td width="9%" align="center" bgcolor="#dfe5e9">第1次付款</td>
                        <td width="9%" align="center" bgcolor="#dfe5e9">时间</td>
                        <td width="9%" align="center" bgcolor="#dfe5e9">第2次付款</td>
                        <td width="9%" align="center" bgcolor="#dfe5e9">时间</td>
                        <td width="9%" align="center" bgcolor="#dfe5e9">第3次付款</td>                        
                        <td width="9%" align="center" bgcolor="#dfe5e9">时间</td>
                        <td width="9%" align="center" bgcolor="#dfe5e9">退税收入</td>                                                
                      </tr>
                  <c:forEach var="data" items="${orderForm.factoryList}">                        
                  <tr>
                    <th align="center">${data.cooperFactory}</th>
                    <th align="center">￥${data.amount}</th>
                    <th align="center">${data.terms}</th>
                    <th align="center">￥${data.payment1}</th>
                    <th align="center"><fmt:formatDate value="${data.paymentDate1}" pattern="yyyy.MM.dd"/></th>
                    <th align="center">￥${data.payment2}</th>
                    <th align="center"><fmt:formatDate value="${data.paymentDate2}" pattern="yyyy.MM.dd"/></th>
                    <th align="center">￥${data.payment3}</th>
                    <th align="center"><fmt:formatDate value="${data.paymentDate3}" pattern="yyyy.MM.dd"/></th>
                    <th align="center">￥${data.taxRevenue}</th>                                        
                  </tr>
                  </c:forEach>
                  </table>                
      			  </div>
          	  <div id="clear"></div>            
            </div>
            <!--产品详细信息 end-->
            
            <!--产品详细信息 begin-->	
    		<div class="titleBg">
            	<div class="fl"><img src="images/rightTitleLeft.jpg" alt="left" /></div>
            	<div class="fl title"><span class="marking1"></span>收入支出汇总</div>
                <div class="fr"><img src="images/rightTitleRight.jpg" alt="left" /></div>
            </div>
            <div id="clear"></div>
            
            <div class="rightBorder">
            
                <div class="property1">
                <table width="100%" border="0" cellspacing="1" cellpadding="5" bgcolor="#dfe5e9">
                	<c:set var="rowNum1" value="1"/>
                	<c:set var="rowNum2" value="1"/>
                	<c:set var="firstNum1" value="0"/>
                	<c:set var="firstNum2" value="0"/>
                	<c:set var="amountNum1" value="0"/>
                	<c:set var="amountNum2" value="0"/>
                	<c:forEach var="income" items="${orderForm.incomeList}">
                		<c:if test="${income.type==true}">
                			<c:set var="rowNum1" value="${rowNum1+1}"/>
                			<c:set var="amountNum1" value="${amountNum1+income.amount}"/>
                		</c:if>
                		<c:if test="${income.type==false}">
                			<c:set var="rowNum2" value="${rowNum2+1}"/>
                			<c:set var="amountNum2" value="${amountNum2+income.amount}"/>
                		</c:if>
                	</c:forEach>
                    <tr>
                        <td width="10%" align="center" bgcolor="#dfe5e9" rowspan="${rowNum1}">收入</td>                        
                        <th width="50%" align="left" bgcolor="#dfe5e9">项目</th>
                        <th width="20%" align="left" bgcolor="#dfe5e9">金额</th>                        
                        <td width="20%" align="center">总收入</td>                        
                    </tr>
                    <c:forEach var="income" items="${orderForm.incomeList}">
                    <c:if test="${income.type==true}">
                    	<tr>
						    <th>${income.cooperFactory}</th>
						    <th>${income.amount}</th>
						    <c:if test="${firstNum1 lt 1}">
						    	<c:set var="firstNum1" value="1"/>
						    	<td rowspan="${rowNum1-1}" align="center">${amountNum1}</td>
						    </c:if>
						</tr>
					</c:if>
					</c:forEach>
					
					<tr>
					    <td align="center"rowspan="${rowNum2}">支出</td>
					    <th align="left">项目</th>
					    <th align="left">金额</th>
					    <td align="center">总支出</td>
					</tr>
					<c:forEach var="expenses" items="${orderForm.incomeList}">
                    <c:if test="${expenses.type==false}">
					<tr>
					    <th>${expenses.cooperFactory}</th>
						<th>${expenses.amount}</th>
						<c:if test="${firstNum2 lt 1}">
							<c:set var="firstNum2" value="1"/>
					    	<td rowspan="${rowNum2-1}" align="left">${amountNum2}</td>
					    </c:if>
					</tr>
					</c:if>					
					</c:forEach>
					<tr>
					    <td align="center">净利润</td>
					    <th>&nbsp;</th>
					    <th>&nbsp;</th>
					    <td align="center">${amountNum1-amountNum2}</td>
					</tr>					  
                  </table>                
      			  </div>
          	  <div id="clear"></div>            
            </div>
            <!--产品详细信息 end-->
            
            <!--统计 end-->
            <div class="total">
                <div class="fl Statistics">&nbsp;</div>
                <div class="fr Operating">                
                    <c:choose>
                    <c:when test="${not empty orderForm}">
                         <li><input name="生成EXL表" type="button" class="button" value="导出EXCEL" onclick="exportExcel(${orderForm.id})"/></li>
                    </c:when>                    
                    <c:otherwise>
                    在添加供应商报价之前，请先在左边列表点击对应货号产品！
                    </c:otherwise>                      
                    </c:choose>                    
                </div>
            </div>
            
    	</div>
    
<script  type="text/javascript">
function exportExcel(id){			
	if(id==null||id == "")
		alert("请先选择要导出的信息！");
	else {
		window.open("<%=basePath%>trade/exportExcel?t=5&ids="+id);
	}
}
function delsellMultiple(){			
	var objs = document.getElementsByName("id");
	var ids='';	
	for(var i=0;i<objs.length;i++){
		if(objs[i].checked){
			ids+=objs[i].value+",";
		}
	}
	if(ids==''){
		alert("请先选择要操作的信息");
		return ;
	}
	ids = ids.substring(0,ids.length - 1);
	
	if(confirm("您确定要删除?")){
		if(ids == ""){
			alert("请先选择要删除的信息！");
			return false;
		}else{
			supplierQuotationService.deleteSupplierQuotationByIds(ids,{
				callback:function(f){alert("删除成功");reload();},
				exceptionHandler:function(message){alert("删除失败，请重试");},
				errorHander:function(err){}
			})
		}
	}
}

function delQuotation(id){
	if(confirm("删除用户，将导致用户无法登陆，确定删除 ？")){
		WIN.showpg();
		userService.delUserById(id,{
			callback:function(f){WIN.closepg();alert("删除成功");reload();},
			exceptionHandler:function(message){WIN.closepg();alert("删除失败，请重试");},
			errorHander:function(err){}
		})
	}
}

function afterSubmit(){
	reload();
}
</script>
</body>
</html>
